<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>全局组件和局部组件</title>
</head>
<script src="../js/vue.js"></script>
<body>

<div id="app">
    <cpn></cpn>
</div>

<div id="app2">
    <cpn2></cpn2>
</div>

</body>

<script>
    // 组件
    const cpn = Vue.extend({
        template:
            `
        <div>
        <h2>标题</h2>
        </div>
        `
    });

    const cpn2 = Vue.extend({
        template:
            `
        <div>
        <h2>标题2</h2>
        </div>
        `
    });

    // 全局组件
    // Vue.component('cpn', cpn);
    const vue = new Vue({
        'el': '#app',
        'data': {},
        'methods': {},
        // 局部组件
        components: {
            cpn: cpn
        }
    });

    const vue2 = new Vue({
        el: '#app2',
        components: {
            cpn2: cpn2
        }
    })
</script>
</html>